/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.llantas.Dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.llantas.modelo.Articulo;

/**
 *
 * @author manuel
 */
@Stateless
public class ArticuloDao extends AbstractDao<Articulo> implements ArticuloDaoLocal {
    @PersistenceContext(unitName = "llantas-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ArticuloDao() {
        super(Articulo.class);
    }
    public boolean findDuplicity(Articulo article) {
      // selecionar consulta
        Query q=em.createNamedQuery("Articulo.findDuplicity");
       //poner parametros
        q.setParameter("marca", article.getMarca());
        q.setParameter("rodado", article.getRodado());
       
        //ejecutar la consulta
        return !q.getResultList().isEmpty();
    }
    public Articulo findDuplicity(ArticuloDao article) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
